/*
 * @lc app=leetcode.cn id=125 lang=swift
 *
 * [125] 验证回文串
 */

// @lc code=start
class Solution {
    func isPalindrome(_ s: String) -> Bool {
        let characters = Array(s)
        var left = 0, right = characters.count - 1
        while left < right {
            if characters[left].isLetter == false && characters[left].isNumber == false {
                left += 1
                continue
            }
            if characters[right].isLetter == false && characters[right].isNumber == false {
                right -= 1
                continue
            }
            
            if characters[left].lowercased() == characters[right].lowercased() {
                left += 1
                right -= 1
            }else{
                return false
            }
        }
        return true
    }
}
// @lc code=end

